﻿<%@ include file="/framework/head.jsp"%>
<%@ page contentType="text/html;charset=UTF-8"%>  
<%@ include file="../../common.jsp"%>
<%
	WarehouseSearchEvent event = (WarehouseSearchEvent)context.getSessionValue("WarehouseSearchEvent");
	ObjectList list = Warehouse.fetch().search(con,event);
	String messages = (String)context.m_req.getAttribute("message");
	if(messages != null){
		out.print("<script language='javascript'>alert('"+ messages +"');</script>");
	}
%>
<!--********************* Part3:JavaScript Code ***************-->
<!--start 客户端脚本区域-->
<script language=javascript>

var list_code = "listWarehouse";

function doSearch()
{


	SetValue("s_Code",GetValue("i_Code")); //编码

	SetValue("s_Name",GetValue("i_Name")); //名称

	SetValue("s_Address",GetValue("i_Address")); //地址

	SetValue("s_Status",GetValue("i_Status")); //是否有效
	
	SetValue("s_CompanyCode",GetValue("i_CompanyCode")); //营运公司代码

	SetValue("s_OrderField",GetValue("i_OrderField")); //排序
	SetValue("s_OrderDesc",getCheckBoxValues("i_OrderDesc")); //升降序
	doCommonSearch();
}

function bizViewWarehouse(id)
{
	viewWin("<%=Config.getSrv()%>?action_code=viewWarehouse&Id="+id);
}


function startUsing() 
{
      var codes = document.getElementsByName("ids");
      var chestr = "";
      for(var i = 0; i < codes.length; i++){
      	if(codes[i].checked){
      		var codeLength = codes[i].title;
      		if(codeLength.length > 6){
      			alert("请选择仓库编码为6位的仓库！");
      			return;
      		}
      		chestr += codeLength+",";
      	}
      }
     
   	  if(chestr == ""){
   	 	alert("请选择仓库！");
   	 	return;
   	  }
   	  
   	  document.getElementById("warehouseCode").value = chestr;	 
      document.formCode1.action="<%=response.encodeURL(root + "/A200001.do")%>";
      formCode1.submit();
}

function stopUsing(){
	  var codes = document.getElementsByName("ids");
      var chestr = "";
      for(var i = 0; i < codes.length; i++){
      	if(codes[i].checked){
      		var codeLength = codes[i].title;
      		if(codeLength.length > 6){
      			alert("请选择仓库编码为6位的仓库！");
      			return;
      		}
      		chestr += codeLength+",";
      	}
      }
     
   	  if(chestr == ""){
   	 	alert("请选择仓库！");
   	 	return;
   	  }
   	  
   	  document.getElementById("warehouseCode").value = chestr;	 
      document.formCode1.action="<%=response.encodeURL(root + "/A200002.do")%>";
      formCode1.submit();
}

function doDelete()
{
	if(!hasChooseRadio("ids"))
	{
		bizMessage("删除","仓库");
		return false;
	}
	if(!bizConfirm("删除","仓库")) return false;
    
	SetAction("deleteWarehouse");
	frm.submit();
}

function doToAdd()
{
	SetAction("toAddWarehouse");
	frm.submit();
}

function doToUpdate()
{
	if(!checkOne("ids")) 
	{
		bizMessage("修改","仓库");
		return false;
	}
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toUpdateWarehouse");
	frm.submit();
}
function doToCopy()
{
	if(!checkOne("ids")) 
	{
		bizMessage("复制","仓库");
		return false;
	}
	SetValue("Id",getCheckBoxValue("ids"));
	SetAction("toCopyWarehouse");
	frm.submit();
}
function doToSend()
{
    if(!checkOne("ids")) 
    {
        bizMessage("配送范围","仓库");
        return false;
    }
    SetValue("Id",getCheckBoxValue("ids"));
    SetAction("toSendCustomer");
    frm.submit();
}
function doToOrder()
{
    if(!checkOne("ids")) 
    {
        bizMessage("分类申购","仓库");
        return false;
    }
    var inputs = document.getElementsByTagName("input");
    //获取input元素数组长度
    var inputsLen = inputs.length;   
    //遍历数组  
    for(var i=0;i<inputsLen;i++){
        //过滤条件目的得到仅需的checkbox对象       
        if((inputs[i].type=="checkbox") && (inputs[i].value==getCheckBoxValue("ids"))){
            //获取已过滤对象的value
            var inputCheckBoxValue = inputs[i].title;
            //进行字符串提取比较
            if(inputCheckBoxValue.length==8||inputCheckBoxValue.length==10){
                SetValue("Id",getCheckBoxValue("ids"));
                SetAction("toOrderCategory");
                frm.submit();
            }else{
            	alert("请选择一具体分库");
            	return false;
            }
            break;
        } 
    }

}

function doToCenterOrder()
{
    if(!checkOne("ids")) 
    {
        bizMessage("中心库分类申购","仓库");
        return false;
    }
    var inputs = document.getElementsByTagName("input");
    //获取input元素数组长度
    var inputsLen = inputs.length;   
    //遍历数组  
    for(var i=0;i<inputsLen;i++){
        //过滤条件目的得到仅需的checkbox对象       
        if((inputs[i].type=="checkbox") && (inputs[i].value==getCheckBoxValue("ids"))){
            //获取已过滤对象的value
            var inputCheckBoxValue = inputs[i].title;
            //进行字符串提取比较
            if(inputCheckBoxValue.length==8||inputCheckBoxValue.length==10){
            	
                SetValue("Id",getCheckBoxValue("ids"));
                SetAction("toCenterOrderCategory");
                frm.submit();
            }else{
            	alert("请选择一具体分库");
            	return false;
            }
            break;
        } 
    }

}

key_InitDefault();
key_RegSubmitHandler(doSearch);
</script>


<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->
<form id=frm action="<%=Config.getSrv()%>" method="post">
<input type=hidden name="action_code" value="">
<input type=hidden name="Id" value="">
<input type=hidden name=sortOrder value="1">

<!--查询条件保留区域-->

<input type=hidden name="s_Code" value="<%=event.getCode()%>"> <!--编码-->

<input type=hidden name="s_Name" value="<%=event.getName()%>"> <!--名称-->

<input type=hidden name="s_Address" value="<%=event.getAddress()%>"> <!--地址-->

<input type=hidden name="s_Status" value="<%=event.getStatus()%>"> <!--是否有效-->

<input type=hidden name="s_CompanyCode" value="<%=event.getStatus()%>"> <!--营运公司代码-->


<%@ include file="/framework/list_head.jsp"%>

<br>
<!--********************* Part5:Search Area ***************-->
<%=uiSearchStart%>>
<%
	int key_tab = 1 ;
%>



	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
			编&nbsp;&nbsp;&nbsp;&nbsp;码：
			<input type="text" class="texts" name="i_Code" size="20" value="<%=event.viewCode()%>" key_tab="<%=key_tab++%>">
			名&nbsp;&nbsp;&nbsp;&nbsp;称：
			<input type="text" class="texts" name="i_Name" size="20" value="<%=event.viewName()%>" key_tab="<%=key_tab++%>">
			地&nbsp;&nbsp;&nbsp;&nbsp;址：
			<input type="text" class="texts" name="i_Address" size="20" value="<%=event.viewAddress()%>" key_tab="<%=key_tab++%>">

		</td>		
	</tr>

	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
			是否有效：
			<%=SelectManager.viewYesOrNoSelect("i_Status",event.viewStatus(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
			营运公司：
			<%=SelectManager.viewWarehouseOfCompanySelect(con,"i_CompanyCode",event.getCompanyCode(),true,"",SelectManager.SELECT_ALL,"","key_tab="+(key_tab++))%>
		</td>	
		
	</tr>

	<%=uiSearchInputTR%>>
		<%=uiSearchInputTDHead%>>
			按&nbsp;排&nbsp;序：

			<select name="i_OrderField">
				<option value="" <%=(event.getOrderField().equals("1"))?"selected":""%>>设置排序字段</option>
				
				
				<option value="CODE" <%=(event.getOrderField().equals("CODE"))?"selected":""%>>编码</option>
				
				<option value="NAME" <%=(event.getOrderField().equals("NAME"))?"selected":""%>>名称</option>
				
				<!-- <option value="FULL_NAME" <%=(event.getOrderField().equals("FULL_NAME"))?"selected":""%>>全称</option> -->
				
				<option value="ADDRESS" <%=(event.getOrderField().equals("ADDRESS"))?"selected":""%>>地址</option>
                <option value="STATUS" <%=(event.getOrderField().equals("STATUS"))?"selected":""%>>是否有效</option>
                <!--  
				
				<option value="CONTACT_PERSON" <%=(event.getOrderField().equals("CONTACT_PERSON"))?"selected":""%>>联系人</option>
				
				<option value="CONTACK_TEL" <%=(event.getOrderField().equals("CONTACK_TEL"))?"selected":""%>>联系电话</option>
				
				<option value="DISPLAY_ORDER" <%=(event.getOrderField().equals("DISPLAY_ORDER"))?"selected":""%>>显示顺序</option>
				
				<option value="REMARK" <%=(event.getOrderField().equals("REMARK"))?"selected":""%>>备注</option>
				
				
				
				<option value="CREATE_USER" <%=(event.getOrderField().equals("CREATE_USER"))?"selected":""%>>创建人</option>
				
				<option value="CREATE_TIME" <%=(event.getOrderField().equals("CREATE_TIME"))?"selected":""%>>创建时间</option>
				
				<option value="LAST_UPDATE_USER" <%=(event.getOrderField().equals("LAST_UPDATE_USER"))?"selected":""%>>最后修改人</option>
				
				<option value="LAST_UDATE_TIME" <%=(event.getOrderField().equals("LAST_UDATE_TIME"))?"selected":""%>>最后修改时间</option>
                -->
				
			</select>
			&nbsp;&nbsp;
			<input type="radio" name="i_OrderDesc" value="false" <%=(event.isOrderDesc()==false)?"checked":""%> >升序
			<input type="radio" name="i_OrderDesc" value="true"  <%=(event.isOrderDesc()==true)?"checked":""%>  >降序
			<input type="button" value="查询" class="buttons" onclick="doSearch();return false;">&nbsp;<input type="button" value="清空" class="buttons" onclick="doClearEvent();return false;">
		</td>
	</tr>

<%=uiSearchEnd%>

<!--列表标题-->
<%=UIManager.addListHeadTitle("仓库列表")%>

<!--********************* Part6:List Area ***************-->

<%=uiListStart%>>

<%@ include file="/framework/list_foot.jsp"%>

<%
	int index = 1 ;
%>	
	<%=uiListHeadTR%>>
		<%=UIManager.addListHeadCheckBox() %>


		<%=UIManager.addListHead("编码",index++)%>

		<%=UIManager.addListHead("名称",index++)%>

		<%=UIManager.addListHead("地址",index++)%>

		<%=UIManager.addListHead("是否有效",index++)%>

		<%=UIManager.addListHead("操作",-1)%>  
	<%=uiListHeadTREnd%>>
	
	<!--data-->
<%
	for(int i=0;i<list.size();i++)
	{
		Warehouse obj = (Warehouse)list.get(i);
%>
	<%=uiListDataTR[i%2]%> align=center>
    	<%=uiListDataTD%>>
    		<input type="checkbox" name="ids" title="<%=obj.viewCode(con)%>" value="<%=obj.getId()%>">
    	</td>
    	<%=uiListDataTD%>><%=obj.viewCode(con)%></td>
    	<%=uiListDataTD%>><%=obj.viewName(con)%></td>
    	<%=uiListDataTD%>><%=obj.viewAddress(con)%></td>
    	<%=uiListDataTD%>><%=obj.viewStatus(con)%></td>

    	<%=uiListDataTD%>>
    		<a href="" onclick="bizViewWarehouse('<%=obj.getId()%>');return false;">浏览</a>
    	</td>
  	</tr>
<%	
	}
%>  

<%@ include file="/framework/list_foot2.jsp"%>

<%=uiListEnd%>


<!--********************* Part7:Action Area ***************-->
<%=uiCommandStart%>>
	<%=uiCommandTR%>>
		<%=uiCommandTD%>>
		<input type=button value="启用库存设置" class="buttons" onclick="startUsing();return false;">
		<input type=button value="停用库存设置" class="buttons" onclick="stopUsing();return false;">
		<input type=button value="　　添加　　" class="buttons" onclick="doToAdd();return false;">
		<!--
		<input type=button value="　　复制　　" class="buttons" onclick="doToCopy();return false;">
		-->
		<input type=button value="　　修改　　" class="buttons" onclick="doToUpdate();return false;">
		<!--<input type=button value="　　删除　　" class="buttons" onclick="doDelete();return false;">-->
        <input type=button value="　配送范围　" class="buttons" onclick="doToSend();return false;">
        <input type=button value="　分类申购　" class="buttons" onclick="doToOrder();return false;">
        <%
        GSOrderCategoryDAO dao= new GSOrderCategoryDAO();
        String providerCode =  dao.dateProperties();
        if(providerCode==null ){
        }else{
        %>
        <input type=button value="　中心库分类申购　" class="buttons" onclick="doToCenterOrder();return false;">
        <%}%>
		</td>
	</tr>	
<%=uiCommandEnd%>
</form>

<form name="formCode1">
	<input type="hidden" name="warehouseCode" id="warehouseCode">
</form>

<%@ include file="/framework/foot.jsp"%>

<!--
	Author    :justin
	FileName  :/system/base/WarehouseList.jsp
-->
